package com.eattravel.controller;

import com.eattravel.dto.PageInfoResult;
import com.eattravel.pojo.Commodity;
import com.eattravel.pojo.Store;
import com.eattravel.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/store")
public class StoreConntroller {
    @Autowired
    StoreService storeService;

    @RequestMapping("/findstorebyid")
    @ResponseBody
    public Store findStoreById(String storeId) {
        Store store = storeService.findStoreById(storeId);
        return store;
    }

    @RequestMapping("/findcommoditybystoreid")
    @ResponseBody
    public PageInfoResult<Commodity> findCommodityByStoreId(String storeId,int currPage) {
        PageInfoResult<Commodity> pageParameter=new PageInfoResult<Commodity>();
        pageParameter.setCurrPage(currPage);
        pageParameter.setPageSize(8);
        pageParameter= storeService.selectCommodityByStoreId(pageParameter,storeId);
        return pageParameter;
    }
}
